#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;scanf("%d", &n);
    vector<int> v(n);
    for (int i = 0 ; i < n ; ++i)
    {
        scanf("%d", &v[i]);    
    }
    sort(v.begin(),v.end());
    int ans=0;
    for (int i = 1 ; i < n ; ++i)
    {
        if(v[i]-v[i-1]==1){
            ans+=1;
        }
    }
    printf("%d\n", ans);
	return 0;
}